<div id="form">
    <?php
    if (empty($_SESSION['mail'])) {
        ?>
        <!--PAS DE SESSION -> formulaire de connexion-->
        <div>
            <form method="post" action="#">
                <input class="case" type="text" value="<?php if (isset($_POST['mail'])) echo htmlentities($_POST['mail']); ?>" placeholder="Mail" name="mail" id="mail" />
                <input class="case" type="password" value="<?php if (isset($_POST['pass'])) echo htmlentities($_POST['pass']); ?>" placeholder="Mot de passe" name="pass" id="pass" /> 
                <input type="submit" value="OK" name="conn" />
                <a href="/~meierj/uml/uml/Inscription/" >
                    Inscription
                </a>
            </form>
        </div>
        <?php
    }
    else {
        //SESSION -> affiche mail
        echo "Bonjour " . $_SESSION['mail'];
        if ($_SESSION['mail'] == 'webmaster@uml.team') {
            echo' | <a href="/~meierj/uml/uml/EspaceWebmaster/">Mon Compte</a> | ';
        } else {
            echo' | <a href="/~meierj/uml/uml/EspaceMembre/">Mon Compte</a> | ';
        }

        echo '<a href = "/~meierj/uml/uml/Includes/deconnexion.php">
        Deconnexion</a>';
    }
    ?>

    <!-- CODE PHP : CONNEXION -->
    <?php
    $message = null;
    $form = true;
    if (!empty($_POST['conn'])) {
        $_POST['mail'] = trim($_POST['mail']);
        $_POST['pass'] = trim($_POST['pass']);
        if (!empty($_POST['mail']) && $_POST['mail'] != null) {
            if (!empty($_POST['pass']) && $_POST['pass'] != null) {
                if (isset($_SESSION['mail'])) {
                    include("/home/ann2/meierj/public_html/uml/uml/Includes/deconnexion.php");
                }
                $mail = $_POST['mail'];
                $mdp = $_POST['pass'];
                $mdp = md5($mdp);
                $_SESSION['mail'] = $_POST['mail'];
            //    require('/home/ann2/meierj/public_html/uml/uml/controleur.php');
                existeMembre($mail, $mdp);
            } else {
                $message = "Merci de saisir votre mot de passe";
            }
        } else {
            $message = "Merci de saisir votre mail";
        }
    }
    if ($form) {
        echo $message;
    }
    ?>
</div>
